<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/examples/analogueModels/ThresholdDecider.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00237.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">ThresholdDecider.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef THRESHOLDDECIDER_H_</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define THRESHOLDDECIDER_H_</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;cmath&gt;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;Decider.h&gt;</span>
<a name="l00009"></a>00009 
<a name="l00024"></a><a class="code" href="a00209.html">00024</a> <span class="keyword">class </span><a class="code" href="a00209.html" title="A simple Decider implementation which only checks for a received signal if the receiving power is abo...">ThresholdDecider</a>:<span class="keyword">public</span> <a class="code" href="a00070.html" title="The basic Decider class.">Decider</a> {
<a name="l00025"></a>00025 <span class="keyword">protected</span>:
<a name="l00026"></a>00026   <span class="keywordtype">int</span> myIndex;
<a name="l00027"></a>00027 
<a name="l00028"></a>00028   <span class="keywordtype">double</span> threshold;
<a name="l00029"></a>00029 
<a name="l00032"></a><a class="code" href="a00209.html#adba3e2c16d773850acaacf8d7d7bf11d">00032</a>   std::map&lt;Signal*, int&gt; <a class="code" href="a00209.html#adba3e2c16d773850acaacf8d7d7bf11d" title="stores the currently receiving signals together with their current state.">currentSignals</a>;
<a name="l00033"></a>00033 
<a name="l00034"></a>00034   <span class="keyword">enum</span> {
<a name="l00035"></a>00035     FIRST,
<a name="l00036"></a>00036     HEADER_OVER,
<a name="l00037"></a>00037     SIGNAL_OVER
<a name="l00038"></a>00038   };
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="keyword">protected</span>:
<a name="l00041"></a>00041 
<a name="l00045"></a><a class="code" href="a00209.html#a0d05cb7c20aff520229a8a051f1f63d3">00045</a>   simtime_t <a class="code" href="a00209.html#a0d05cb7c20aff520229a8a051f1f63d3" title="handles Signals passed the first time.">handleNewSignal</a>(<a class="code" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>* s){
<a name="l00046"></a>00046     <span class="comment">//set the state the signal will be in the next time we get it</span>
<a name="l00047"></a>00047     <a class="code" href="a00209.html#adba3e2c16d773850acaacf8d7d7bf11d" title="stores the currently receiving signals together with their current state.">currentSignals</a>[s] = HEADER_OVER;
<a name="l00048"></a>00048 
<a name="l00049"></a>00049     log(<span class="stringliteral">&quot;First processing of this signal. Scheduling it to end of header to decide if Signal should be received.&quot;</span>);
<a name="l00050"></a>00050     <span class="comment">//we say that the length of the header is at 10% of the length of the signal</span>
<a name="l00051"></a>00051     <span class="keywordflow">return</span> s-&gt;<a class="code" href="a00192.html#a7c4710243cf87caf7dfc9f313e2619b2" title="Returns the point in time when the receiving of the Signal started at the receiver module...">getReceptionStart</a>() + 0.10 * s-&gt;<a class="code" href="a00192.html#a22f7cede842dbfe895cd8aedf708402f" title="Returns the duration of the signal transmission.">getDuration</a>();
<a name="l00052"></a>00052   }
<a name="l00053"></a>00053 
<a name="l00057"></a><a class="code" href="a00209.html#a5cca0d77477336f95f56215d7a43c704">00057</a>   simtime_t <a class="code" href="a00209.html#a5cca0d77477336f95f56215d7a43c704" title="handles the Signal when passed after after end of the header.">handleHeaderOver</a>(std::map&lt;Signal*, int&gt;::iterator&amp; it){
<a name="l00058"></a>00058     log(<span class="stringliteral">&quot;Second receive of a signal from Phy - Deciding if packet should be received - Let&#39;s try to receive it.&quot;</span>);
<a name="l00059"></a>00059     <span class="comment">//we don&#39;t really do something after the header, so we only update the next state</span>
<a name="l00060"></a>00060     it-&gt;second = SIGNAL_OVER;
<a name="l00061"></a>00061     <span class="keywordflow">return</span> it-&gt;first-&gt;getReceptionEnd();
<a name="l00062"></a>00062   }
<a name="l00063"></a>00063 
<a name="l00067"></a><a class="code" href="a00209.html#a6e559163ddd38ef6256b9faa67a46e63">00067</a>   simtime_t <a class="code" href="a00209.html#a6e559163ddd38ef6256b9faa67a46e63" title="handles the signal when passed at the end of the signal.">handleSignalOver</a>(std::map&lt;Signal*, int&gt;::iterator&amp; it, <a class="code" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a> frame) {
<a name="l00068"></a>00068     log(<span class="stringliteral">&quot;Last receive of signal from Phy - Deciding if the packet could be received correctly...&quot;</span>);
<a name="l00069"></a>00069 
<a name="l00070"></a>00070     <span class="comment">//get the receiving power from the signal (calculated at each call of</span>
<a name="l00071"></a>00071     <span class="comment">//this method</span>
<a name="l00072"></a>00072     <span class="comment">//Mapping* receivingPower = it-&gt;first-&gt;getReceivingPower();</span>
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 
<a name="l00075"></a>00075     <span class="comment">//------print the mappings----------------------</span>
<a name="l00076"></a>00076     ev &lt;&lt; <span class="stringliteral">&quot;Sending power mapping: &quot;</span> &lt;&lt; endl;
<a name="l00077"></a>00077     <a class="code" href="a00209.html#a4d46b0c578c9e817ea8084f53fc0e8e4" title="Quick and ugly printing of a two dimensional mapping.">printMapping</a>(it-&gt;first-&gt;getTransmissionPower());
<a name="l00078"></a>00078 
<a name="l00079"></a>00079     <a class="code" href="a00058.html" title="Represents a not changeable mapping (mathematical function) from domain with at least the time to a A...">ConstMapping</a>* receivingPower;
<a name="l00080"></a>00080 
<a name="l00081"></a>00081     simtime_t delay = it-&gt;first-&gt;getPropagationDelay();
<a name="l00082"></a>00082     <span class="keywordflow">if</span>(delay == 0)
<a name="l00083"></a>00083       receivingPower = it-&gt;first-&gt;getTransmissionPower()-&gt;<a class="code" href="a00058.html#a741e083fb18412a3d9cde7eac3dced10" title="returns a deep copy of this mapping instance.">constClone</a>();
<a name="l00084"></a>00084     <span class="keywordflow">else</span>
<a name="l00085"></a>00085       receivingPower = <span class="keyword">new</span> <a class="code" href="a00056.html" title="Moves another ConstMapping in its time dimension.">ConstDelayedMapping</a>(it-&gt;first-&gt;getTransmissionPower(), delay);
<a name="l00086"></a>00086 
<a name="l00087"></a>00087     std::list&lt;ConstMapping*&gt; attList = it-&gt;first-&gt;getAttenuation();
<a name="l00088"></a>00088     <span class="keywordtype">int</span> count = 1;
<a name="l00089"></a>00089     <span class="keywordflow">for</span>(std::list&lt;ConstMapping*&gt;::const_iterator aIt = attList.begin();
<a name="l00090"></a>00090       aIt != attList.end(); ++aIt){
<a name="l00091"></a>00091 
<a name="l00092"></a>00092       ev &lt;&lt; endl;
<a name="l00093"></a>00093       ev &lt;&lt; <span class="stringliteral">&quot; multiplied with Attenuation &quot;</span> &lt;&lt; count;
<a name="l00094"></a>00094       <span class="keywordflow">switch</span>(count){
<a name="l00095"></a>00095       <span class="keywordflow">case</span> 1:
<a name="l00096"></a>00096         ev &lt;&lt; <span class="stringliteral">&quot;(Radiostate)&quot;</span>;
<a name="l00097"></a>00097         <span class="keywordflow">break</span>;
<a name="l00098"></a>00098       <span class="keywordflow">case</span> 2:
<a name="l00099"></a>00099         ev &lt;&lt; <span class="stringliteral">&quot;(Pathloss)&quot;</span>;
<a name="l00100"></a>00100         <span class="keywordflow">break</span>;
<a name="l00101"></a>00101       <span class="keywordflow">case</span> 3:
<a name="l00102"></a>00102         ev &lt;&lt; <span class="stringliteral">&quot;(Random time and freq attenuation)&quot;</span>;
<a name="l00103"></a>00103         <span class="keywordflow">break</span>;
<a name="l00104"></a>00104       <span class="keywordflow">case</span> 4:
<a name="l00105"></a>00105         ev &lt;&lt; <span class="stringliteral">&quot;(Random freq only attenuation)&quot;</span>;
<a name="l00106"></a>00106         <span class="keywordflow">break</span>;
<a name="l00107"></a>00107       }
<a name="l00108"></a>00108       ev &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; endl;
<a name="l00109"></a>00109       <a class="code" href="a00209.html#a4d46b0c578c9e817ea8084f53fc0e8e4" title="Quick and ugly printing of a two dimensional mapping.">printMapping</a>(*aIt);
<a name="l00110"></a>00110       ++count;
<a name="l00111"></a>00111 
<a name="l00112"></a>00112       <a class="code" href="a00058.html" title="Represents a not changeable mapping (mathematical function) from domain with at least the time to a A...">ConstMapping</a>* tmp = <a class="code" href="a00138.html#a11550dc6dc55beb5a14def9ffb501a40" title="Multiplies the passed functions element-wise with each other and returns the result in a new Function...">MappingUtils::multiply</a>(*receivingPower, **aIt, <a class="code" href="a00013.html#a8523627cdc70492e5e0935b9a3a78cc4" title="Zero value of a Argument value.">Argument::MappedZero</a>);
<a name="l00113"></a>00113       <span class="keyword">delete</span> receivingPower;
<a name="l00114"></a>00114       receivingPower = tmp;
<a name="l00115"></a>00115 
<a name="l00116"></a>00116       ev &lt;&lt; endl;
<a name="l00117"></a>00117       ev &lt;&lt; <span class="stringliteral">&quot; result:&quot;</span> &lt;&lt; endl;
<a name="l00118"></a>00118       <a class="code" href="a00209.html#a4d46b0c578c9e817ea8084f53fc0e8e4" title="Quick and ugly printing of a two dimensional mapping.">printMapping</a>(receivingPower);
<a name="l00119"></a>00119     }
<a name="l00120"></a>00120 
<a name="l00121"></a>00121     ev &lt;&lt; endl;
<a name="l00122"></a>00122     ev &lt;&lt; <span class="stringliteral">&quot;Receiving power calculated.\n&quot;</span>;
<a name="l00123"></a>00123     ev &lt;&lt; <span class="stringliteral">&quot;Signal receiving power. (Should be same as above)\n&quot;</span>;
<a name="l00124"></a>00124     <a class="code" href="a00209.html#a4d46b0c578c9e817ea8084f53fc0e8e4" title="Quick and ugly printing of a two dimensional mapping.">printMapping</a>(it-&gt;first-&gt;getReceivingPower());
<a name="l00125"></a>00125 
<a name="l00126"></a>00126     ev &lt;&lt; endl;
<a name="l00127"></a>00127     ev &lt;&lt; <span class="stringliteral">&quot;Threshold is &quot;</span> &lt;&lt; toDecibel(threshold) &lt;&lt; <span class="stringliteral">&quot;dbm&quot;</span> &lt;&lt; endl;
<a name="l00128"></a>00128     <span class="comment">//----------------------------------------------</span>
<a name="l00129"></a>00129 
<a name="l00130"></a>00130     <span class="keywordtype">bool</span> toWeak = <span class="keyword">false</span>;
<a name="l00131"></a>00131 
<a name="l00132"></a>00132     <span class="comment">//iterate over receiving power mapping and chekc if every value is bigger</span>
<a name="l00133"></a>00133     <span class="comment">//then the threshold</span>
<a name="l00134"></a>00134     <a class="code" href="a00059.html" title="Defines an const iterator for a ConstMapping which is able to iterate over the Mapping.">ConstMappingIterator</a>* mIt = receivingPower-&gt;createConstIterator();
<a name="l00135"></a>00135 
<a name="l00136"></a>00136     <span class="keywordflow">while</span>(mIt-&gt;<a class="code" href="a00059.html#a4a6348a453418da95978e570fec046fc" title="Returns true if the current position of the iterator is in range of the function.">inRange</a>()){
<a name="l00137"></a>00137       <span class="keywordflow">if</span>(mIt-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt; threshold){
<a name="l00138"></a>00138         <span class="comment">// print receiving power if too weak</span>
<a name="l00139"></a>00139         ev &lt;&lt; <span class="stringliteral">&quot;receiving power: &quot;</span> &lt;&lt; mIt-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>() &lt;&lt; endl;
<a name="l00140"></a>00140         toWeak = <span class="keyword">true</span>;
<a name="l00141"></a>00141         <span class="keywordflow">break</span>;
<a name="l00142"></a>00142       }
<a name="l00143"></a>00143 
<a name="l00144"></a>00144       <span class="keywordflow">if</span>(!mIt-&gt;<a class="code" href="a00059.html#ad4bac7233c154b7086c6124d2e21be49" title="Returns true if the iterator has a next value it can iterate to on a call to &quot;next()&quot;.">hasNext</a>())
<a name="l00145"></a>00145         <span class="keywordflow">break</span>;
<a name="l00146"></a>00146 
<a name="l00147"></a>00147       mIt-&gt;<a class="code" href="a00059.html#afdafa6870cd19b3d35674a7bc777585d" title="Iterates to the next position of the Mapping.">next</a>();
<a name="l00148"></a>00148     }
<a name="l00149"></a>00149 
<a name="l00150"></a>00150     <span class="keyword">delete</span> mIt;
<a name="l00151"></a>00151     <span class="keyword">delete</span> receivingPower;
<a name="l00152"></a>00152 
<a name="l00153"></a>00153     <span class="keywordflow">if</span>(toWeak){
<a name="l00154"></a>00154       log(<span class="stringliteral">&quot;...signal is to weak -&gt; discard.&quot;</span>);
<a name="l00155"></a>00155     } <span class="keywordflow">else</span> {
<a name="l00156"></a>00156       log(<span class="stringliteral">&quot;...strong enough -&gt; forwarding it to Mac layer.&quot;</span>);
<a name="l00157"></a>00157       <a class="code" href="a00070.html#ac0f72556cb799d883b4219cab58320bb" title="A pointer to the physical layer of this Decider.">phy</a>-&gt;<a class="code" href="a00079.html#ad81919dcafb2d568303e9ed362dafd93" title="Called to send an AirFrame with DeciderResult to the MACLayer.">sendUp</a>(frame, <span class="keyword">new</span> <a class="code" href="a00075.html" title="A class to represent the result of a processed packet (that is not noise) by the Decider.">DeciderResult</a>(<span class="keyword">true</span>));
<a name="l00158"></a>00158     }
<a name="l00159"></a>00159 
<a name="l00160"></a>00160     <a class="code" href="a00209.html#adba3e2c16d773850acaacf8d7d7bf11d" title="stores the currently receiving signals together with their current state.">currentSignals</a>.erase(it);
<a name="l00161"></a>00161     <span class="keywordflow">return</span> <a class="code" href="a00070.html#a7fbb5a5f14ae118e40d7db1903be6d51" title="simtime that tells the Phy-Layer not to pass an AirFrame again">Decider::notAgain</a>;
<a name="l00162"></a>00162   }
<a name="l00163"></a>00163 
<a name="l00164"></a>00164 
<a name="l00165"></a>00165   <span class="comment">//----------Utility methods----------------------------</span>
<a name="l00166"></a>00166   <span class="keywordtype">void</span> log(std::string msg) {
<a name="l00167"></a>00167     ev &lt;&lt; <span class="stringliteral">&quot;[Host &quot;</span> &lt;&lt; myIndex &lt;&lt; <span class="stringliteral">&quot;] - PhyLayer(Decider): &quot;</span> &lt;&lt; msg &lt;&lt; endl;
<a name="l00168"></a>00168   }
<a name="l00169"></a>00169 
<a name="l00170"></a>00170   <span class="keywordtype">double</span> toDecibel(<span class="keywordtype">double</span> v){
<a name="l00171"></a>00171     <span class="keywordflow">return</span> 10.0 * log10(v);
<a name="l00172"></a>00172   }
<a name="l00173"></a>00173 
<a name="l00174"></a>00174   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;
<a name="l00175"></a>00175   std::string toString(T v, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length){
<a name="l00176"></a>00176     <span class="keywordtype">char</span>* tmp = <span class="keyword">new</span> <span class="keywordtype">char</span>[255];
<a name="l00177"></a>00177     sprintf(tmp, <span class="stringliteral">&quot;%.2f&quot;</span>, v);
<a name="l00178"></a>00178 
<a name="l00179"></a>00179     std::string result(tmp);
<a name="l00180"></a>00180     <span class="keyword">delete</span>[] tmp;
<a name="l00181"></a>00181     <span class="keywordflow">while</span>(result.length() &lt; length)
<a name="l00182"></a>00182       result += <span class="stringliteral">&quot; &quot;</span>;
<a name="l00183"></a>00183     <span class="keywordflow">return</span> result;
<a name="l00184"></a>00184   }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186   std::string toString(simtime_t_cref v, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length){
<a name="l00187"></a>00187     <span class="keywordflow">return</span> toString(SIMTIME_DBL(v), length);
<a name="l00188"></a>00188   }
<a name="l00189"></a>00189 
<a name="l00193"></a><a class="code" href="a00209.html#a4d46b0c578c9e817ea8084f53fc0e8e4">00193</a>   <span class="keywordtype">void</span> <a class="code" href="a00209.html#a4d46b0c578c9e817ea8084f53fc0e8e4" title="Quick and ugly printing of a two dimensional mapping.">printMapping</a>(<span class="keyword">const</span> <a class="code" href="a00058.html" title="Represents a not changeable mapping (mathematical function) from domain with at least the time to a A...">ConstMapping</a>* m)<span class="keyword"> const </span>{
<a name="l00194"></a>00194     m-&gt;<a class="code" href="a00058.html#a526e8d5b948e9b2ce9d729e66b162e13" title="Prints the Mapping to an output stream.">print</a>(ev.getOStream(), 1000., 1e-9, <span class="stringliteral">&quot;GHz\\ms&quot;</span>, &amp;<a class="code" href="a00085.html#ad4360e7d88c881d06ee61033ad99d66f" title="Shortcut to the frequency Dimension, same as &#39;Dimension(&quot;frequency&quot;)&#39;, but spares the parsing of a ...">Dimension::frequency</a>);
<a name="l00195"></a>00195   }
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 <span class="keyword">public</span>:
<a name="l00198"></a>00198   <a class="code" href="a00209.html" title="A simple Decider implementation which only checks for a received signal if the receiving power is abo...">ThresholdDecider</a>(<a class="code" href="a00079.html" title="This class is the interface for a Decider to the BasePhyLayer.">DeciderToPhyInterface</a>* <a class="code" href="a00070.html#ac0f72556cb799d883b4219cab58320bb" title="A pointer to the physical layer of this Decider.">phy</a>, <span class="keywordtype">double</span> sensitivity, <span class="keywordtype">int</span> myIndex, <span class="keywordtype">bool</span> bDebug):
<a name="l00199"></a>00199     <a class="code" href="a00070.html" title="The basic Decider class.">Decider</a>(phy), myIndex(myIndex), threshold(0), <a class="code" href="a00209.html#adba3e2c16d773850acaacf8d7d7bf11d" title="stores the currently receiving signals together with their current state.">currentSignals</a>() {}
<a name="l00200"></a>00200 
<a name="l00209"></a><a class="code" href="a00209.html#a5ed56dc12cece481ab983da1853daff4">00209</a>   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="a00209.html#a5ed56dc12cece481ab983da1853daff4" title="Initialize the decider from XML map data.">initFromMap</a>(<span class="keyword">const</span> <a class="code" href="a00070.html#a7f3ee545f2ae8b0d8d1814c98917f5b6" title="Used at initialisation to pass the parameters to the AnalogueModel and Decider.">ParameterMap</a>&amp; params) {
<a name="l00210"></a>00210     <span class="keywordtype">bool</span>                         bInitSuccess = <span class="keyword">true</span>;
<a name="l00211"></a>00211     ParameterMap::const_iterator it           = params.find(<span class="stringliteral">&quot;threshold&quot;</span>);
<a name="l00212"></a>00212     <span class="keywordflow">if</span>(it != params.end()) {
<a name="l00213"></a>00213       threshold = ParameterMap::mapped_type(it-&gt;second).doubleValue();
<a name="l00214"></a>00214     }
<a name="l00215"></a>00215     <span class="keywordflow">else</span> {
<a name="l00216"></a>00216       opp_warning(<span class="stringliteral">&quot;ERROR: No threshold parameter defined for ThresholdDecider!&quot;</span>);
<a name="l00217"></a>00217         bInitSuccess = <span class="keyword">false</span>;
<a name="l00218"></a>00218     }
<a name="l00219"></a>00219     <span class="keywordflow">return</span> <a class="code" href="a00209.html#a5ed56dc12cece481ab983da1853daff4" title="Initialize the decider from XML map data.">Decider::initFromMap</a>(params) &amp;&amp; bInitSuccess;
<a name="l00220"></a>00220   }
<a name="l00221"></a>00221 
<a name="l00226"></a><a class="code" href="a00209.html#aa8d099cd7a5ade60ca70a291239bdc78">00226</a>   <span class="keyword">virtual</span> simtime_t <a class="code" href="a00209.html#aa8d099cd7a5ade60ca70a291239bdc78" title="this method is called by the BasePhylayer whenever it gets a AirFrame (from another phy or self sched...">processSignal</a>(<a class="code" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a> frame) {
<a name="l00227"></a>00227     <a class="code" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>* s = &amp;frame-&gt;getSignal();
<a name="l00228"></a>00228 
<a name="l00229"></a>00229     <span class="comment">//Check if we already know this signal...</span>
<a name="l00230"></a>00230     std::map&lt;Signal*, int&gt;::iterator it = <a class="code" href="a00209.html#adba3e2c16d773850acaacf8d7d7bf11d" title="stores the currently receiving signals together with their current state.">currentSignals</a>.find(s);
<a name="l00231"></a>00231 
<a name="l00232"></a>00232     <span class="comment">//if not, we handle it as a new signal</span>
<a name="l00233"></a>00233     <span class="keywordflow">if</span>(it == <a class="code" href="a00209.html#adba3e2c16d773850acaacf8d7d7bf11d" title="stores the currently receiving signals together with their current state.">currentSignals</a>.end()) {
<a name="l00234"></a>00234       <span class="keywordflow">return</span> <a class="code" href="a00209.html#a0d05cb7c20aff520229a8a051f1f63d3" title="handles Signals passed the first time.">handleNewSignal</a>(s);
<a name="l00235"></a>00235 
<a name="l00236"></a>00236     <span class="comment">//otherwise handle it depending on the state it currently is in</span>
<a name="l00237"></a>00237     } <span class="keywordflow">else</span> {
<a name="l00238"></a>00238       <span class="keywordflow">switch</span>(it-&gt;second) {
<a name="l00239"></a>00239       <span class="keywordflow">case</span> HEADER_OVER:
<a name="l00240"></a>00240         <span class="keywordflow">return</span> <a class="code" href="a00209.html#a5cca0d77477336f95f56215d7a43c704" title="handles the Signal when passed after after end of the header.">handleHeaderOver</a>(it);
<a name="l00241"></a>00241 
<a name="l00242"></a>00242       <span class="keywordflow">case</span> SIGNAL_OVER:
<a name="l00243"></a>00243         <span class="keywordflow">return</span> <a class="code" href="a00209.html#a6e559163ddd38ef6256b9faa67a46e63" title="handles the signal when passed at the end of the signal.">handleSignalOver</a>(it, frame);
<a name="l00244"></a>00244 
<a name="l00245"></a>00245       <span class="keywordflow">default</span>:
<a name="l00246"></a>00246         <span class="keywordflow">break</span>;
<a name="l00247"></a>00247       }
<a name="l00248"></a>00248     }
<a name="l00249"></a>00249 
<a name="l00250"></a>00250     <span class="comment">//we should never get here!</span>
<a name="l00251"></a>00251     assert(<span class="keyword">false</span>);
<a name="l00252"></a>00252     <span class="keywordflow">return</span> 0;
<a name="l00253"></a>00253   }
<a name="l00254"></a>00254 
<a name="l00255"></a><a class="code" href="a00209.html#a245351047ec242c42497116e66b2d902">00255</a>   <span class="keyword">virtual</span> <a class="code" href="a00044.html" title="Provides information about the current state of the channel:">ChannelState</a> <a class="code" href="a00209.html#a245351047ec242c42497116e66b2d902" title="A function that returns information about the channel state.">getChannelState</a>()<span class="keyword"> const </span>{
<a name="l00256"></a>00256     <span class="keywordflow">return</span> <a class="code" href="a00044.html" title="Provides information about the current state of the channel:">ChannelState</a>(<span class="keyword">false</span>, 0);
<a name="l00257"></a>00257   }
<a name="l00258"></a><a class="code" href="a00209.html#af67f3a22ff4eaf2e77e2e71d04885040">00258</a>   <span class="keyword">virtual</span> simtime_t <a class="code" href="a00209.html#af67f3a22ff4eaf2e77e2e71d04885040" title="This function is called by the PhyLayer to hand over a ChannelSenseRequest.">handleChannelSenseRequest</a>(ChannelSenseRequest*) {
<a name="l00259"></a>00259     <span class="keywordflow">return</span> <a class="code" href="a00070.html#a7fbb5a5f14ae118e40d7db1903be6d51" title="simtime that tells the Phy-Layer not to pass an AirFrame again">Decider::notAgain</a>;
<a name="l00260"></a>00260   }
<a name="l00261"></a>00261 };
<a name="l00262"></a>00262 
<a name="l00263"></a>00263 <span class="preprocessor">#endif </span><span class="comment">/*TESTDECIDER_H_*/</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>ThresholdDecider.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:29 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
